//
//  VerticalButton.m
//  YanXiuWang
//
//  Created by 慧趣小歪 on 16/12/27.
//  Copyright © 2016年 小分队. All rights reserved.
//

#import "VerticalButton.h"
#import <UIKit/UIKit.h>
@implementation VerticalButton

- (void)layoutSubviews {
    [super layoutSubviews];
    UIFont *font = self.titleLabel.font ?: [UIFont systemFontOfSize:15];
    CGFloat lineHeight = ceil(font.lineHeight);
    CGSize size = self.bounds.size;

    UIImage *image = [self imageForState:self.state];
    
    CGFloat contentHeight = image.size.height + _textOffset + lineHeight;
    CGFloat imageY = (size.height - contentHeight) / 2 + _iconOffset;
    
    self.imageView.frame = CGRectMake((size.width - image.size.width) / 2, imageY, image.size.width, image.size.height);
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.frame = CGRectMake(0, imageY + image.size.height + _textOffset, size.width, lineHeight);
}

@end
